//package com.lagou.edu.config;
//
//import com.lagou.edu.annotations.A;
//import com.lagou.edu.annotations.T;
//import org.springframework.beans.BeansException;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.config.BeanPostProcessor;
//import org.springframework.context.annotation.AnnotationConfigApplicationContext;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.support.XmlWebApplicationContext;
//
//import java.lang.reflect.Field;
//import java.lang.reflect.InvocationHandler;
//import java.lang.reflect.Method;
//import java.lang.reflect.Proxy;
//
//@Component
//public class MyBeanDefinitionProcessorConfig implements BeanPostProcessor {
//
//    @Autowired
//    DataSourceTransactionManager dataSourceTransactionManager;
//
//    @Override
//    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
////        return importTransaction(bean);
//        return bean;
//    }
//
//    @Override
//    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
//        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
//        for (Field field :  bean.getClass().getDeclaredFields()){
//            if (field.isAnnotationPresent(A.class)){
//                field.setAccessible(true);
//                try {
//                    field.set(bean,applicationContext.getBeanFactory().
//                            createBean(field.getType()));
//                } catch (IllegalAccessException e) {
//                    e.printStackTrace();
//                }
//            }
//        }
//        return bean;
//    }
//
//
//
//}
